<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>AJAX 数据库实例</title>
</head>
<body>
    <form>
        <select name="users" onchange="showSite(this.value)">
            <option value="">选择一个网站:</option>
            <option value="1">Google</option>
            <option value="2">淘宝</option>
            <option value="3">菜鸟教程</option>
            <option value="4">微博</option>
            <option value="5">Facebook</option>
        </select>
    </form>
    <br>
    <div id="txtHint"><b>网站信息显示在这里...</b></div>
<script>
    function showSite(site) {
        var xmlHttp;
        if(site =="") {
            document.getElementById("txtHint").innerHTML="";
            retrun;
        }
        if(window.XMLHttpRequest) {
            xmlHttp = new XMLHttpRequest();
        }else {
            xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
        }
        xmlHttp.onreadystatechange = function() {
            if(xmlHttp.readyState == 4 && xmlHttp.status == 200) {
                document.getElementById("txtHint").innerHTML = xmlHttp.responseText;
            }
        }
        xmlHttp.open("GET", "getsite_mysql.php?q=" + site, true);
        xmlHttp.send();
    }
</script>
</body>
</html>